package com.yu.POJO;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: LittleFisher
 * @Date: 2021/05/23/16:11
 * @Description:
 */
public class Student {
    private int id;
    private String sno;
    private String name;
    private String password;
    private int clazz_id;
    @JsonIgnore
    private Clazz clazz;
    @JsonIgnore
    private StuInfo stuInfo;

    //clazz 属性方便前端调用
    private String clazzName;
    private String dept;

    //stuInfo 属性方便前端调用
    private String age;
    private String sex;
    private String address;
    private String phone;
    private String dormitory;//宿舍
    private String native_place;//籍贯

    public void clazz_InfoToStu(){
        /*
        * 把clazz stuInfo 的内容拿出来 方便easyui使用
        *
        * */
        if(clazz!=null){
            this.clazzName = clazz.getName();
            this.dept = clazz.getDept();

        }

        if(stuInfo!=null){
            this.age = stuInfo.getAge();
            this.sex = stuInfo.getSex();
            this.address = stuInfo.getAddress();
            this.phone = stuInfo.getPhone();
            this.dormitory = stuInfo.getDormitory();
            this.native_place = stuInfo.getNative_place();
        }

    }

    public void stuToClazz_Info(){
        /*
         * 与上面相反 easyui 的数据放在clazz 和stuInfo方便后端使用
         *
         * */
        clazz = new Clazz();
        clazz.setName(this.clazzName);
        clazz.setDept(this.dept);
        clazz.setId(this.clazz_id);

        stuInfo = new StuInfo();
        stuInfo.setId(this.id);
        stuInfo.setAddress(this.address);
        stuInfo.setAge(this.age);
        stuInfo.setSex(this.sex);
        stuInfo.setPhone(this.phone);
        stuInfo.setDormitory(this.dormitory);
        stuInfo.setNative_place(this.native_place);
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", sno='" + sno + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", clazz_id=" + clazz_id +
                ", clazz=" + clazz +
                ", stuInfo=" + stuInfo +
                ", clazzName='" + clazzName + '\'' +
                ", dept='" + dept + '\'' +
                ", age='" + age + '\'' +
                ", sex='" + sex + '\'' +
                ", address='" + address + '\'' +
                ", phone='" + phone + '\'' +
                ", dormitory='" + dormitory + '\'' +
                ", native_place='" + native_place + '\'' +
                '}';
    }

    public String getClazzName() {
        return clazzName;
    }

    public void setClazzName(String clazzName) {
        this.clazzName = clazzName;
    }

    public String getDept() {
        return dept;
    }

    public void setDept(String dept) {
        this.dept = dept;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getDormitory() {
        return dormitory;
    }

    public void setDormitory(String dormitory) {
        this.dormitory = dormitory;
    }

    public String getNative_place() {
        return native_place;
    }

    public void setNative_place(String native_place) {
        this.native_place = native_place;
    }

    public int getClazz_id() {
        return clazz_id;
    }

    public void setClazz_id(int clazz_id) {
        this.clazz_id = clazz_id;
    }


    public StuInfo getStuInfo() {
        return stuInfo;
    }

    public void setStuInfo(StuInfo stuInfo) {
        this.stuInfo = stuInfo;
    }

    public Clazz getClazz() {
        return clazz;
    }

    public void setClazz(Clazz clazz) {
        this.clazz = clazz;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getSno() {
        return sno;
    }

    public void setSno(String sno) {
        this.sno = sno;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Student() {
    }

    public Student(int id, String sno, String name, String password, int clazz_id) {
        this.id = id;
        this.sno = sno;
        this.name = name;
        this.password = password;
        this.clazz_id = clazz_id;
    }

    public Student(String sno, String name, String password) {
        this.sno = sno;
        this.name = name;
        this.password = password;
    }

    public Student(String sno, String name, String password, int clazz_id) {
        this.sno = sno;
        this.name = name;
        this.password = password;
        this.clazz_id = clazz_id;
    }
}
